package com.zj.business.reader;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author zhangbo
 * @program: PDF-helper
 * @ClassName PdfReaderContext
 * @description: $
 * @date 2023-05-16 20:42:52
 */
@Slf4j
@Component
public class PdfReaderContext {

    private IPdfReader pdfReader;

    /**
     * 设置读取工具
     *
     * @param pdfReader pdf帮助类
     */
    public void setPdfReader(IPdfReader pdfReader) {
        this.pdfReader = pdfReader;
    }

    /**
     * 读取文件内容
     *
     * @param fileName 文件名字
     * @return 返回
     */
    public String executeOperation(String fileName){
        String contents = null;
        try {
            contents = pdfReader.read(fileName);
        } catch (Exception ex) {
            log.error("读取pdf异常：", ex);
        }
        return contents;
    }

}
